package com.cq.hd.admin.controller;

import com.cq.hd.admin.annotation.RequiresPermissionsDesc;
import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.member.api.TbFeedbackApi;
import com.cq.hd.member.api.dto.FeedbackPageDto;
import com.cq.hd.member.api.vo.FeedbackPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "反馈建议相关接口")
@Slf4j
@RestController
@RequestMapping("/feedback")
public class TbFeedbackController extends BaseController {

    private TbFeedbackApi feedbackApi;

    @Autowired
    public void setFeedbackApi(TbFeedbackApi feedbackApi) {
        this.feedbackApi = feedbackApi;
    }

    @ApiOperation(value = "反馈建议列表")
    @ApiImplicitParam(name = "feedbackPageDto", value = "反馈建议实体", paramType = "query", dataType = "FeedbackPageDto")
    @ApiResponse(response = FeedbackPageVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("feedback:feedback:list")
    @RequiresPermissionsDesc(menu = {"反馈建议", "反馈建议"}, button = "查询")
    @GetMapping("/page")
    public Result<Page<FeedbackPageVo>> pageFeedback(FeedbackPageDto feedbackPageDto) {
        return feedbackApi.pageFeedback(feedbackPageDto);
    }

    @ApiOperation(value = "反馈建议详情")
    @ApiImplicitParam(name = "id", value = "反馈建议id", required = true, paramType = "query", dataType = "Long")
    @ApiResponse(response = FeedbackPageVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("feedback:feedback:detail")
    @RequiresPermissionsDesc(menu = {"反馈建议", "反馈建议"}, button = "详情")
    @GetMapping("/details")
    public Result<FeedbackPageVo> details(Long id) {
        return feedbackApi.details(id);
    }

}
